package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 请求方法限定
 * @author stone
 * @date 2022/07/11 16:09
 */
@Controller//("method") → @RequestMapping的value属性做的才是窄化请求，@Controller的value属性做的组件id的指定
@RequestMapping("method")
public class RequestMethodLimitController {

    //localhost:8080/method/get
    //@RequestMapping(value = "get",method = RequestMethod.GET)
    @GetMapping("get")
    @ResponseBody
    public BaseRespVo methodGet() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setData("METHOD GET");
        return baseRespVo;
    }
    //localhost:8080/method/post
    //@RequestMapping(value = "post",method = RequestMethod.POST)
    @PostMapping("post")
    @ResponseBody
    public BaseRespVo methodPost() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setData("METHOD POST");
        return baseRespVo;
    }
    //localhost:8080/method/double
    @RequestMapping(value = "double",method = {RequestMethod.POST,RequestMethod.GET})
    @ResponseBody
    public BaseRespVo methodDouble() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setData("METHOD Double");
        return baseRespVo;
    }
}
